package com.ruoyi.system.domain;

import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseIdEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;

/**
 * 积分记录对象 yh_point_record
 * 
 * @author ruoyi
 * @date 2023-06-06
 */
@Data
@ApiModel(value = "YhPointRecord", description = "积分记录对象")
public class YhPointRecord extends BaseIdEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    @ApiModelProperty("id")
    private String id;

    /** 用户Id */
    @Excel(name = "用户Id")
    @ApiModelProperty("用户Id")
    private String memberId;

    /** 积分来源（扫码：SCAN_CODE，提成：COMMISSION */
    @Excel(name = "积分来源", readConverterExp = "积分来源（扫码：SCAN_CODE，提成：COMMISSION")
    @ApiModelProperty("积分来源（扫码：SCAN_CODE，提成：COMMISSION")
    private String type;

    /** 关联ID */
    @Excel(name = "关联ID")
    @ApiModelProperty("关联ID")
    private String associationId;

    /** 积分数量 */
    @Excel(name = "积分数量")
    @ApiModelProperty("积分数量")
    private Double point;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /** 更新时间 */
    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public YhPointRecord(){}

    public YhPointRecord(String memberId, Double point, String associationId, String type){
        this.associationId = associationId;
        this.point = point;
        this.memberId = memberId;
        this.type = type;
    }




    public <T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> wrapper=new QueryWrapper<>();

        wrapper.eq(StringUtils.isNotEmpty(id),"id" , id);
        wrapper.eq(StringUtils.isNotEmpty(memberId),"member_id" , memberId);
        wrapper.eq(StringUtils.isNotEmpty(type),"type" , type);
        wrapper.eq(StringUtils.isNotEmpty(associationId),"association_id" , associationId);
        wrapper.eq(point != null,"point" , point);
        wrapper.eq(createTime != null,"create_time" , createTime);
        wrapper.eq(updateTime != null,"update_time" , updateTime);

        wrapper.orderByDesc("create_time");
        return wrapper;
    }

}
